<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>课程购买</title>
    <link rel="stylesheet" href="/static/css/buy-course.css?v=v1" />
</head>
<body>
<div class="modal-content modal-pay">
    <div class="pay-content">
        <div class="course-dialog">
            <div class="course-header">
                <div class="course-dialog-img">
                    <img src="${course.cover!}" alt="">
                </div>
                <div class="course-dialog-info">
                    <h3>${course.courseName!}</h3>
                    <p>总课时：${course.lessonNum!} 课时</p>
                    <div class="course-dialog-price">
                        <h3>${course.price/100} 元</h3>
                        <#if course.sourcePrice gt course.price>
                            <del>原价 ${(course.sourcePrice/100)} 元</del>
                            (<span style="color: red;font-weight: bold">${course.price * 10/course.sourcePrice} </span> 折)
                        </#if>
                    </div>
                </div>
            </div>
        </div>
        <div class="course-info-top">
            您的可用现金为 ￥<span>${userAccount.balance/100}</span>元;
        </div>
        <div class="course-info-footer">
            <div class="pay-wrap">
                <div class="pay-money">应付金额 ￥<span id="current_price">${course.price/100}</span>元</div>
                <div class="pay-search" id="pay-use-weixin" style="display: block">
                    <div class="weixin-qrcode" id="qrcode-image">
                        <img src="/static/images/qr-code.png" style="width: 138px;height: 138px;">
                    </div>
                    <div class="weixin-words"><img src="/static/images/icons/icon-wechat.png" alt=""><span>微信扫码支付</span></div>
                </div>
                <div class="pay-money-asset" id="pay-use-money" style="display: none">
                    <div class="asset-count">账户余额 ￥<span style="color: red">${userAccount.balance/100}</span></div>
                    <a class="btn-pay-asset">账户支付</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/libs/jquery/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="/static/libs/layui-v2.6.8/layui.js"></script>
<script type="text/javascript" src="/static/libs/jquery/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="/static/js/wxJSAPI.js"></script>
<script type="text/javascript" src="/static/js/order.js?v=1"></script>
<script type="text/javascript">
    var userMoney = ${userAccount.balance};
    var thisPrice = ${course.price};
    var params = {
        otherId: ${course.courseId},
        orderType: 'COURSE',
        payType: 'WXPAY'
    };
    //选择开通类型
    $(document).ready(function () {
        $('.btn-pay-asset').on('click', function () {
            orderCreate(params);
        });
        initCourseOrder();
    });

    function initCourseOrder() {
        if (userMoney >= thisPrice) {
            $('#pay-use-money').css('display', 'block');
            $('#pay-use-weixin').css('display', 'none');
            //使用现金支付
        } else {
            //使用微信支付接口的
            $('#pay-use-money').css('display', 'none');
            $('#pay-use-weixin').css('display', 'block');
            orderCreate(params);
        }
    }
</script>
</body>
</html>